#!/usr/bin/bash
#
# Put customizations to your image in this file.

PATH=/opt/local/gnu/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin

# Exit if any commands fail
set -o errexit

lam_ver=7.4

# Configuring image specific packages
echo "* Configuring image specific packages.";
# manual page: https://www.ldap-account-manager.org/static/doc/manual-onePage/index.html
#wget http://prdownloads.sourceforge.net/lam/ldap-account-manager-${lam_ver}.tar.bz2?download -O /root/ldap-account-manager-${lam_ver}.tar.bz2
wget --no-check-certificate https://minio.itime.biz:4443/downloads/phpapp/lam/ldap-account-manager-${lam_ver}.tar.bz2 -O /root/ldap-account-manager-${lam_ver}.tar.bz2
tar xjf /root/ldap-account-manager-${lam_ver}.tar.bz2 -C /opt

echo "* Create ssl folder for nginx"
mkdir /opt/local/etc/nginx/ssl

cp /opt/ldap-account-manager-${lam_ver}/config/config.cfg.sample /opt/ldap-account-manager-${lam_ver}/config/config.cfg
chown -R www:www /opt/ldap-account-manager-${lam_ver}
# link ldap-account-manager
ln -s /opt/ldap-account-manager-${lam_ver} /opt/lam

echo "* Cleanup home/admin because of delegate dataset usage"
rm -rf /home/admin/.[^.]*

# Clean up
echo "* Cleaning up."
rm -rf /root/*

# Prepare image for provisioning
sm-prepare-image -y
